package com.newegg.app.qec.util;

import android.app.Activity;
import android.content.SharedPreferences;

/**
 * Created by Allen on 2017/12/8.
 * 存储数据
 */
public class Constants {
    public static final String SHAREDPREFERENCESNAME = "";

    //获取SharedPreferences里面的值
    public static String getStringByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getString(name, "");
    }

    public static int getIntByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getInt(name, 0);
    }


    //设置SharedPreferences里面的值
    public static void setStringByName(Activity mActivity, String name, String value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putString(name, value).commit();
    }

    public static void setIntByName(Activity mActivity, String name, Integer value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putInt(name, value).commit();
    }

    //是否登录状态记录
    public static boolean getLoginByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getBoolean(name, false);
    }

    public static void setLoginByName(Activity mActivity, String name, Boolean value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putBoolean(name, value).commit();
    }

    public static void clearLoginByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().clear().commit();
    }

    //设置头像存储
    public static String getHeadPhotoByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getString(name, "");
    }

    public static void setHeadPhotoByName(Activity mActivity, String name, String value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putString(name, value).commit();
    }

    public static void clearHeadPhotByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().clear().commit();
    }

    //记录注册的token
    public static void setRegisterTokenByName(Activity mActivity, String name, String value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putString(name, value).commit();
    }

    public static String getRegisterTokenByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getString(name, "");
    }

    //记录注册的验证码
    public static void setRegisterCodeByName(Activity mActivity, String name, String value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putString(name, value).commit();
    }

    public static String getRegisterCodeByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getString(name, "");
    }

    //记录注册电话号码
    public static void setPhoneNumberByName(Activity mActivity, String name, String value) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        preferences.edit().putString(name, value).commit();
    }

    public static String getPhoneNumberByName(Activity mActivity, String name) {
        SharedPreferences preferences = mActivity.getSharedPreferences(Constants.SHAREDPREFERENCESNAME, 0);
        return preferences.getString(name, "");
    }
}
